package com.cn.why.film.filmindex.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;

/**
 * webSocket配置类
 */
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketCongfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config){
        //设置服务器广播消息的基础路径
        config.enableSimpleBroker("/topic");
        //设置客户端订阅消息的基础路径
        config.setApplicationDestinationPrefixes("/app");
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        //前台连接的url
        registry.addEndpoint("/portfolio-stomp").withSockJS();
    }
}
